<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册登录</title>
    <link rel="stylesheet" href="./css/bootstrap.css">
    <link rel="stylesheet" href="./css/bootstrap-icons/bootstrap-icons.css">
    <script src="./js/jquery-3.7.1.min.js"></script>
    <script src="./js/bootstrap.bundle.js"></script>
    <style>
        .center-container {
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }

        .card {
            max-width: 1000px;
            width: 100%;
        }
    </style>
</head>

<body>
    <div class="center-container">
        <div class="card shadow">
            <div class="card-body">
                <div class="row g-0">
                    <!-- LOGO -->
                    <div class="col-12">
                        <div class="d-flex align-items-center justify-content-start">
                            <img src="./img/logo1.jpg" style="width: 40px;height: 40px;" alt="">
                            <h5>智能宠物管家</h5>
                        </div>
                    </div>
                    <!-- 左侧图片 -->
                    <div class="col-xl-6 col-md-6 col-xs-6">
                        <div class="d-flex align-items-center justify-content-center h-100 ml-4">
                            <img class="img-fluid img-rounded" style="width: 100%;height: 600px ; max-width: 800px;"
                                src="./img/注册页面背景图.png">
                        </div>
                    </div>
                    <!-- 右侧表单 -->
                    <div class="col-xl-6 col-md-6 col-xs-6 p-5">
                        <h2 class="mb-4">注册</h2>
                        <form action="" class="was-validated">
                            <div class="form-row">
                                <div class="col-md-12 mb-3">
                                    <label for="validationServer01">用户名</label>
                                    <input type="text" class="form-control" id="validationServer01"
                                        pattern="[\\u4e00-\\u9fa5A-Za-z0-9]{3,20}" required>
                                    <div class="invalid-feedback">请输入有效的用户名，3-20位，可包含中文、字母或数字</div>
                                    <div class="valid-feedback">验证通过</div>
                                </div>
                            </div>
                            <div class="form-row">
                                <div class="col-md-6 mb-3">
                                    <label for="validationServer03">邮箱</label>
                                    <input type="email" class="form-control" id="validationServer03"
                                        aria-describedby="validationServer03Feedback" required>
                                    <div id="validationServer03Feedback" class="invalid-feedback">请输入有效的邮箱地址</div>
                                    <div class="valid-feedback">验证通过</div>
                                </div>
                                <div class="col-md-6 mb-3">
                                    <label for="validationServer04">城市</label>
                                    <input type="text" class="form-control" id="validationServer04"
                                        pattern="[\\u4e00-\\u9fa5]{2,10}" aria-describedby="validationServer04Feedback"
                                        required>
                                    <div id="validationServer04Feedback" class="invalid-feedback">请输入中文城市名，2-10个汉字</div>
                                    <div class="valid-feedback">验证通过</div>
                                </div>
                            </div>
                            <div class="form-row">
                                <div class="col-md-12 mb-3">
                                    <label for="validationServer06">设置密码</label>
                                    <input type="password" class="form-control" id="validationServer06"
                                        pattern="(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{8,20}" required>
                                    <div class="invalid-feedback">密码长度8-20位，需同时包含字母和数字</div>
                                    <div class="valid-feedback">验证通过</div>
                                </div>
                                <div class="col-md-12 mb-3">
                                    <label for="validationServer07">确认密码</label>
                                    <input type="password" class="form-control" id="validationServer07" required>
                                    <div class="invalid-feedback">两次输入的密码不一致</div>
                                    <div class="valid-feedback">验证通过</div>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" value="" id="invalidCheck3"
                                        aria-describedby="invalidCheck3Feedback" required>
                                    <label class="form-check-label" for="invalidCheck3">我已阅读并同意<a href="#"
                                            class="text-primary">服务条款</a>和<a href="#"
                                            class="text-primary">隐私政策</a></label>
                                    <div id="invalidCheck3Feedback" class="invalid-feedback">必须同意条款才能注册</div>
                                    <div class="valid-feedback">验证通过</div>
                                </div>
                            </div>
                            <button class="btn btn-primary w-100" type="submit">注册账号</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        // 密码验证逻辑
        document.getElementById('validationServer07').addEventListener('input', function () {
            const password = document.getElementById('validationServer06').value;
            const confirmPassword = this.value;

            if (password !== confirmPassword) {
                this.setCustomValidity('两次输入的密码不一致');
                this.classList.remove('is-valid');
                this.classList.add('is-invalid');
            } else {
                this.setCustomValidity('');
                this.classList.remove('is-invalid');
                this.classList.add('is-valid');
            }
        });
    </script>
</body>

</html>